#ifndef _SINGLETON_H_
#define _SINGLETON_H_

namespace easy2d {

	template <typename T> 
	class Singleton
	{
	public:
		static T& instance()
		{
			if (ms_Singleton == 0)
				ms_Singleton = new T;
			return (*ms_Singleton);
		}

		static void release()
		{
			delete ms_Singleton;
			ms_Singleton = 0;
		}

	protected:
		Singleton() { ms_Singleton = 0; }
		virtual ~Singleton() { }

	private:
		static T* ms_Singleton;
	};

	template <typename T>
	T* Singleton <T>::ms_Singleton = 0;

}	// namespace

#endif
